dir="/mnt/nas/datasets/diction"
dates=("0808" 
        "0811" "0812" "0813" "0814" "0815" 
        "0818" "0819" "0820" "0821" "0822" 
        "0825" "0826" "0827" "0828" "0829"
        "0901" "0902" "0903" "0904" "0905"
        "0908" "0909" "0910" "0911" "0912"
        "0915" "0916" "0917")  # 正确的数组定义方式
categories=("coat" "leather" "sweater")

# 初始化一个关联数组来存储每个类别的总clo(diff)数量
declare -A category_totals

for category in "${categories[@]}"; do
    # 初始化当前类别的总和为0
    category_totals[$category]=0

    # leather 到 0825 为止 if date > 0825 and category=leather then continue

    for date in "${dates[@]}"; do

        # 如果是 leather 类别且日期大于 0825，则跳过
        if [[ "$category" == "leather" && "$date" > "0825" ]]; then
            continue  # 跳过这个日期，继续下一个
        fi

        count=$(grep -c "\.jpg" "$dir"/"$category""$date"_img/names.txt)
        count2=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo/names.txt)
        count3=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo_diff/names.txt)

        # 累加到当前类别的总和中
        category_totals[$category]=$((category_totals[$category] + count3))

        echo $category "Date: $date, JPG count: $count"
        echo $category "Date: $date clo(diff+sim), JPG count: $count2"
        echo $category "Date: $date clo(diff), JPG count: $count3"
        # echo
    done
done    

# 输出每个类别的clo(diff)总数量
echo "---> Total clo(diff) counts per category: <---"
for category in "${categories[@]}"; do
    echo "$category: ${category_totals[$category]}"
done

dir="/mnt/nas/datasets/diction"
dates=("0818" "0819" "0820" "0821")  # 正确的数组定义方式
categories=("jean")

# 初始化一个关联数组来存储每个类别的总clo(diff)数量
declare -A category_totals

for category in "${categories[@]}"; do
    # 初始化当前类别的总和为0
    category_totals[$category]=0

    for date in "${dates[@]}"; do
        count=$(grep -c "\.jpg" "$dir"/"$category""$date"_img/names.txt)
        count2=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo/names.txt)
        count3=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo_diff/names.txt)

        # 累加到当前类别的总和中
        category_totals[$category]=$((category_totals[$category] + count3))

        # echo $category "Date: $date, JPG count: $count"
        # echo $category "Date: $date clo(diff+sim), JPG count: $count2"
        # echo $category "Date: $date clo(diff), JPG count: $count3"
        # echo
    done
done    

# 输出每个类别的clo(diff)总数量
echo "---> Total clo(diff) counts per category: <---"
for category in "${categories[@]}"; do
    echo "$category: ${category_totals[$category]}"
done